import java.util.Random;

public class Test {

    public static void inorderArray(int[] array) {
        for (int i = 0; i < array.length; i++) {
            array[i] = i;
        }
    }
    public static void notinorderArray(int[] array) {
        for (int i = 0; i < array.length; i++) {
            array[i] = array.length - i;
        }
    }
    public static void initArray(int[] array) {
        Random random = new Random();
        for (int i = 0; i < array.length; i++) {
            array[i] = random.nextInt(array.length);
        }
    }
    public static void main(String[] args) {




    }

    public static void main2(String[] args) {
        class Solution {
            public void duplicateZeros(int[] arr) {
                // 1. 找到cur 和 dest 的位置
                int cur = 0;
                int dest = 1;
                for(;cur < arr.length  ; cur++) {
                    if(arr[cur] != 0 ) {
                        dest++;
                    } else {
                        dest += 2;
                        if(dest == arr.length) {
                            dest--;
                            arr[dest] = 0;
                            dest--;
                            cur--;
                            break;
                        }
                        if(dest == arr.length -1) {
                            break;
                        }
                    }
                }
                // 2. 从后面往前遍历
                for(;cur >= 0 ;cur--) {
                    if(arr[cur] != 0) {
                        arr[dest] = arr[cur];
                    } else {
                        arr[dest] = arr[cur];
                        dest--;
                        arr[dest] = 0;
                    }
                    dest--;
                }
            }
        }

    }
}
